
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Uploaded Files and Upload Handlers &#8212; Django 1.11.22.dev20190603194737 documentation</title>
    <link rel="stylesheet" href="../../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
    <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../_static/doctools.js"></script>
    <script type="text/javascript" src="../../_static/language_data.js"></script>
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="Forms" href="../forms/index.html" />
    <link rel="prev" title="File storage API" href="storage.html" />



 
<script type="text/javascript" src="../../templatebuiltins.js"></script>
<script type="text/javascript">
(function($) {
    if (!django_template_builtins) {
       // templatebuiltins.js missing, do nothing.
       return;
    }
    $(document).ready(function() {
        // Hyperlink Django template tags and filters
        var base = "../templates/builtins.html";
        if (base == "#") {
            // Special case for builtins.html itself
            base = "";
        }
        // Tags are keywords, class '.k'
        $("div.highlight\\-html\\+django span.k").each(function(i, elem) {
             var tagname = $(elem).text();
             if ($.inArray(tagname, django_template_builtins.ttags) != -1) {
                 var fragment = tagname.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + tagname + "</a>");
             }
        });
        // Filters are functions, class '.nf'
        $("div.highlight\\-html\\+django span.nf").each(function(i, elem) {
             var filtername = $(elem).text();
             if ($.inArray(filtername, django_template_builtins.tfilters) != -1) {
                 var fragment = filtername.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + filtername + "</a>");
             }
        });
    });
})(jQuery);
</script>


  </head><body>

    <div class="document">
  <div id="custom-doc" class="yui-t6">
    <div id="hd">
      <h1><a href="../../index.html">Django 1.11.22.dev20190603194737 documentation</a></h1>
      <div id="global-nav">
        <a title="Home page" href="../../index.html">Home</a>  |
        <a title="Table of contents" href="../../contents.html">Table of contents</a>  |
        <a title="Global index" href="../../genindex.html">Index</a>  |
        <a title="Module index" href="../../py-modindex.html">Modules</a>
      </div>
      <div class="nav">
    &laquo; <a href="storage.html" title="File storage API">previous</a>
     |
    <a href="../index.html" title="API Reference" accesskey="U">up</a>
   |
    <a href="../forms/index.html" title="Forms">next</a> &raquo;</div>
    </div>

    <div id="bd">
      <div id="yui-main">
        <div class="yui-b">
          <div class="yui-g" id="ref-files-uploads">
            
  <div class="section" id="s-module-django.core.files.uploadedfile">
<span id="s-uploaded-files-and-upload-handlers"></span><span id="module-django.core.files.uploadedfile"></span><span id="uploaded-files-and-upload-handlers"></span><h1>Uploaded Files and Upload Handlers<a class="headerlink" href="#module-django.core.files.uploadedfile" title="Permalink to this headline">¶</a></h1>
<div class="section" id="s-uploaded-files">
<span id="uploaded-files"></span><h2>Uploaded files<a class="headerlink" href="#uploaded-files" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="django.core.files.uploadedfile.UploadedFile">
<em class="property">class </em><code class="descname">UploadedFile</code><a class="reference internal" href="../../_modules/django/core/files/uploadedfile.html#UploadedFile"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.files.uploadedfile.UploadedFile" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>During file uploads, the actual file data is stored in <a class="reference internal" href="../request-response.html#django.http.HttpRequest.FILES" title="django.http.HttpRequest.FILES"><code class="xref py py-attr docutils literal notranslate"><span class="pre">request.FILES</span></code></a>. Each entry in this dictionary is an
<code class="docutils literal notranslate"><span class="pre">UploadedFile</span></code> object (or a subclass) – a simple wrapper around an uploaded
file. You’ll usually use one of these methods to access the uploaded content:</p>
<dl class="method">
<dt id="django.core.files.uploadedfile.UploadedFile.read">
<code class="descclassname">UploadedFile.</code><code class="descname">read</code>()<a class="headerlink" href="#django.core.files.uploadedfile.UploadedFile.read" title="Permalink to this definition">¶</a></dt>
<dd><p>Read the entire uploaded data from the file. Be careful with this method:
if the uploaded file is huge it can overwhelm your system if you try to
read it into memory. You’ll probably want to use <code class="docutils literal notranslate"><span class="pre">chunks()</span></code> instead; see
below.</p>
</dd></dl>

<dl class="method">
<dt id="django.core.files.uploadedfile.UploadedFile.multiple_chunks">
<code class="descclassname">UploadedFile.</code><code class="descname">multiple_chunks</code>(<em>chunk_size=None</em>)<a class="headerlink" href="#django.core.files.uploadedfile.UploadedFile.multiple_chunks" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if the uploaded file is big enough to require reading in
multiple chunks. By default this will be any file larger than 2.5 megabytes,
but that’s configurable; see below.</p>
</dd></dl>

<dl class="method">
<dt id="django.core.files.uploadedfile.UploadedFile.chunks">
<code class="descclassname">UploadedFile.</code><code class="descname">chunks</code>(<em>chunk_size=None</em>)<a class="headerlink" href="#django.core.files.uploadedfile.UploadedFile.chunks" title="Permalink to this definition">¶</a></dt>
<dd><p>A generator returning chunks of the file. If <code class="docutils literal notranslate"><span class="pre">multiple_chunks()</span></code> is
<code class="docutils literal notranslate"><span class="pre">True</span></code>, you should use this method in a loop instead of <code class="docutils literal notranslate"><span class="pre">read()</span></code>.</p>
<p>In practice, it’s often easiest simply to use <code class="docutils literal notranslate"><span class="pre">chunks()</span></code> all the time.
Looping over <code class="docutils literal notranslate"><span class="pre">chunks()</span></code> instead of using <code class="docutils literal notranslate"><span class="pre">read()</span></code> ensures that large
files don’t overwhelm your system’s memory.</p>
</dd></dl>

<p>Here are some useful attributes of <code class="docutils literal notranslate"><span class="pre">UploadedFile</span></code>:</p>
<dl class="attribute">
<dt id="django.core.files.uploadedfile.UploadedFile.name">
<code class="descclassname">UploadedFile.</code><code class="descname">name</code><a class="headerlink" href="#django.core.files.uploadedfile.UploadedFile.name" title="Permalink to this definition">¶</a></dt>
<dd><p>The name of the uploaded file (e.g. <code class="docutils literal notranslate"><span class="pre">my_file.txt</span></code>).</p>
</dd></dl>

<dl class="attribute">
<dt id="django.core.files.uploadedfile.UploadedFile.size">
<code class="descclassname">UploadedFile.</code><code class="descname">size</code><a class="headerlink" href="#django.core.files.uploadedfile.UploadedFile.size" title="Permalink to this definition">¶</a></dt>
<dd><p>The size, in bytes, of the uploaded file.</p>
</dd></dl>

<dl class="attribute">
<dt id="django.core.files.uploadedfile.UploadedFile.content_type">
<code class="descclassname">UploadedFile.</code><code class="descname">content_type</code><a class="headerlink" href="#django.core.files.uploadedfile.UploadedFile.content_type" title="Permalink to this definition">¶</a></dt>
<dd><p>The content-type header uploaded with the file (e.g. <em class="mimetype">text/plain</em>
or <em class="mimetype">application/pdf</em>). Like any data supplied by the user, you
shouldn’t trust that the uploaded file is actually this type. You’ll still
need to validate that the file contains the content that the content-type
header claims – “trust but verify.”</p>
</dd></dl>

<dl class="attribute">
<dt id="django.core.files.uploadedfile.UploadedFile.content_type_extra">
<code class="descclassname">UploadedFile.</code><code class="descname">content_type_extra</code><a class="headerlink" href="#django.core.files.uploadedfile.UploadedFile.content_type_extra" title="Permalink to this definition">¶</a></dt>
<dd><p>A dictionary containing extra parameters passed to the <code class="docutils literal notranslate"><span class="pre">content-type</span></code>
header. This is typically provided by services, such as Google App Engine,
that intercept and handle file uploads on your behalf. As a result your
handler may not receive the uploaded file content, but instead a URL or
other pointer to the file. (see <a class="reference external" href="https://www.ietf.org/rfc/rfc2388.txt">RFC 2388</a> section 5.3).</p>
</dd></dl>

<dl class="attribute">
<dt id="django.core.files.uploadedfile.UploadedFile.charset">
<code class="descclassname">UploadedFile.</code><code class="descname">charset</code><a class="headerlink" href="#django.core.files.uploadedfile.UploadedFile.charset" title="Permalink to this definition">¶</a></dt>
<dd><p>For <em class="mimetype">text/*</em> content-types, the character set (i.e. <code class="docutils literal notranslate"><span class="pre">utf8</span></code>)
supplied by the browser. Again, “trust but verify” is the best policy here.</p>
</dd></dl>

<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>Like regular Python files, you can read the file line-by-line simply by
iterating over the uploaded file:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">uploadedfile</span><span class="p">:</span>
    <span class="n">do_something_with</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
</pre></div>
</div>
<p class="last">Lines are split using <a class="reference external" href="https://www.python.org/dev/peps/pep-0278">universal newlines</a>. The following are recognized
as ending a line: the Unix end-of-line convention <code class="docutils literal notranslate"><span class="pre">'\n'</span></code>, the Windows
convention <code class="docutils literal notranslate"><span class="pre">'\r\n'</span></code>, and the old Macintosh convention <code class="docutils literal notranslate"><span class="pre">'\r'</span></code>.</p>
</div>
<p>Subclasses of <code class="docutils literal notranslate"><span class="pre">UploadedFile</span></code> include:</p>
<dl class="class">
<dt id="django.core.files.uploadedfile.TemporaryUploadedFile">
<em class="property">class </em><code class="descname">TemporaryUploadedFile</code><a class="reference internal" href="../../_modules/django/core/files/uploadedfile.html#TemporaryUploadedFile"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.files.uploadedfile.TemporaryUploadedFile" title="Permalink to this definition">¶</a></dt>
<dd><p>A file uploaded to a temporary location (i.e. stream-to-disk). This class
is used by the
<a class="reference internal" href="#django.core.files.uploadhandler.TemporaryFileUploadHandler" title="django.core.files.uploadhandler.TemporaryFileUploadHandler"><code class="xref py py-class docutils literal notranslate"><span class="pre">TemporaryFileUploadHandler</span></code></a>. In
addition to the methods from <a class="reference internal" href="#django.core.files.uploadedfile.UploadedFile" title="django.core.files.uploadedfile.UploadedFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">UploadedFile</span></code></a>, it has one additional
method:</p>
</dd></dl>

<dl class="method">
<dt id="django.core.files.uploadedfile.TemporaryUploadedFile.temporary_file_path">
<code class="descclassname">TemporaryUploadedFile.</code><code class="descname">temporary_file_path</code>()<a class="reference internal" href="../../_modules/django/core/files/uploadedfile.html#TemporaryUploadedFile.temporary_file_path"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.files.uploadedfile.TemporaryUploadedFile.temporary_file_path" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the full path to the temporary uploaded file.</p>
</dd></dl>

<dl class="class">
<dt id="django.core.files.uploadedfile.InMemoryUploadedFile">
<em class="property">class </em><code class="descname">InMemoryUploadedFile</code><a class="reference internal" href="../../_modules/django/core/files/uploadedfile.html#InMemoryUploadedFile"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.files.uploadedfile.InMemoryUploadedFile" title="Permalink to this definition">¶</a></dt>
<dd><p>A file uploaded into memory (i.e. stream-to-memory). This class is used
by the <a class="reference internal" href="#django.core.files.uploadhandler.MemoryFileUploadHandler" title="django.core.files.uploadhandler.MemoryFileUploadHandler"><code class="xref py py-class docutils literal notranslate"><span class="pre">MemoryFileUploadHandler</span></code></a>.</p>
</dd></dl>

</div>
<div class="section" id="s-module-django.core.files.uploadhandler">
<span id="s-built-in-upload-handlers"></span><span id="module-django.core.files.uploadhandler"></span><span id="built-in-upload-handlers"></span><h2>Built-in upload handlers<a class="headerlink" href="#module-django.core.files.uploadhandler" title="Permalink to this headline">¶</a></h2>
<p>Together the <a class="reference internal" href="#django.core.files.uploadhandler.MemoryFileUploadHandler" title="django.core.files.uploadhandler.MemoryFileUploadHandler"><code class="xref py py-class docutils literal notranslate"><span class="pre">MemoryFileUploadHandler</span></code></a> and
<a class="reference internal" href="#django.core.files.uploadhandler.TemporaryFileUploadHandler" title="django.core.files.uploadhandler.TemporaryFileUploadHandler"><code class="xref py py-class docutils literal notranslate"><span class="pre">TemporaryFileUploadHandler</span></code></a> provide Django’s default file upload
behavior of reading small files into memory and large ones onto disk. They
are located in <code class="docutils literal notranslate"><span class="pre">django.core.files.uploadhandler</span></code>.</p>
<dl class="class">
<dt id="django.core.files.uploadhandler.MemoryFileUploadHandler">
<em class="property">class </em><code class="descname">MemoryFileUploadHandler</code><a class="reference internal" href="../../_modules/django/core/files/uploadhandler.html#MemoryFileUploadHandler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.files.uploadhandler.MemoryFileUploadHandler" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>File upload handler to stream uploads into memory (used for small files).</p>
<dl class="class">
<dt id="django.core.files.uploadhandler.TemporaryFileUploadHandler">
<em class="property">class </em><code class="descname">TemporaryFileUploadHandler</code><a class="reference internal" href="../../_modules/django/core/files/uploadhandler.html#TemporaryFileUploadHandler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.files.uploadhandler.TemporaryFileUploadHandler" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Upload handler that streams data into a temporary file using
<a class="reference internal" href="#django.core.files.uploadedfile.TemporaryUploadedFile" title="django.core.files.uploadedfile.TemporaryUploadedFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">TemporaryUploadedFile</span></code></a>.</p>
</div>
<div class="section" id="s-writing-custom-upload-handlers">
<span id="s-custom-upload-handlers"></span><span id="writing-custom-upload-handlers"></span><span id="custom-upload-handlers"></span><h2>Writing custom upload handlers<a class="headerlink" href="#writing-custom-upload-handlers" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="django.core.files.uploadhandler.FileUploadHandler">
<em class="property">class </em><code class="descname">FileUploadHandler</code><a class="reference internal" href="../../_modules/django/core/files/uploadhandler.html#FileUploadHandler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.files.uploadhandler.FileUploadHandler" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>All file upload handlers should be subclasses of
<code class="docutils literal notranslate"><span class="pre">django.core.files.uploadhandler.FileUploadHandler</span></code>. You can define upload
handlers wherever you wish.</p>
<div class="section" id="s-required-methods">
<span id="required-methods"></span><h3>Required methods<a class="headerlink" href="#required-methods" title="Permalink to this headline">¶</a></h3>
<p>Custom file upload handlers <strong>must</strong> define the following methods:</p>
<dl class="method">
<dt id="django.core.files.uploadhandler.FileUploadHandler.receive_data_chunk">
<code class="descclassname">FileUploadHandler.</code><code class="descname">receive_data_chunk</code>(<em>raw_data</em>, <em>start</em>)<a class="reference internal" href="../../_modules/django/core/files/uploadhandler.html#FileUploadHandler.receive_data_chunk"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.files.uploadhandler.FileUploadHandler.receive_data_chunk" title="Permalink to this definition">¶</a></dt>
<dd><p>Receives a “chunk” of data from the file upload.</p>
<p><code class="docutils literal notranslate"><span class="pre">raw_data</span></code> is a byte string containing the uploaded data.</p>
<p><code class="docutils literal notranslate"><span class="pre">start</span></code> is the position in the file where this <code class="docutils literal notranslate"><span class="pre">raw_data</span></code> chunk
begins.</p>
<p>The data you return will get fed into the subsequent upload handlers’
<code class="docutils literal notranslate"><span class="pre">receive_data_chunk</span></code> methods. In this way, one handler can be a
“filter” for other handlers.</p>
<p>Return <code class="docutils literal notranslate"><span class="pre">None</span></code> from <code class="docutils literal notranslate"><span class="pre">receive_data_chunk</span></code> to short-circuit remaining
upload handlers from getting this chunk. This is useful if you’re
storing the uploaded data yourself and don’t want future handlers to
store a copy of the data.</p>
<p>If you raise a <code class="docutils literal notranslate"><span class="pre">StopUpload</span></code> or a <code class="docutils literal notranslate"><span class="pre">SkipFile</span></code> exception, the upload
will abort or the file will be completely skipped.</p>
</dd></dl>

<dl class="method">
<dt id="django.core.files.uploadhandler.FileUploadHandler.file_complete">
<code class="descclassname">FileUploadHandler.</code><code class="descname">file_complete</code>(<em>file_size</em>)<a class="reference internal" href="../../_modules/django/core/files/uploadhandler.html#FileUploadHandler.file_complete"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.files.uploadhandler.FileUploadHandler.file_complete" title="Permalink to this definition">¶</a></dt>
<dd><p>Called when a file has finished uploading.</p>
<p>The handler should return an <code class="docutils literal notranslate"><span class="pre">UploadedFile</span></code> object that will be stored
in <code class="docutils literal notranslate"><span class="pre">request.FILES</span></code>. Handlers may also return <code class="docutils literal notranslate"><span class="pre">None</span></code> to indicate that
the <code class="docutils literal notranslate"><span class="pre">UploadedFile</span></code> object should come from subsequent upload handlers.</p>
</dd></dl>

</div>
<div class="section" id="s-optional-methods">
<span id="optional-methods"></span><h3>Optional methods<a class="headerlink" href="#optional-methods" title="Permalink to this headline">¶</a></h3>
<p>Custom upload handlers may also define any of the following optional methods or
attributes:</p>
<dl class="attribute">
<dt id="django.core.files.uploadhandler.FileUploadHandler.chunk_size">
<code class="descclassname">FileUploadHandler.</code><code class="descname">chunk_size</code><a class="headerlink" href="#django.core.files.uploadhandler.FileUploadHandler.chunk_size" title="Permalink to this definition">¶</a></dt>
<dd><p>Size, in bytes, of the “chunks” Django should store into memory and feed
into the handler. That is, this attribute controls the size of chunks
fed into <code class="docutils literal notranslate"><span class="pre">FileUploadHandler.receive_data_chunk</span></code>.</p>
<p>For maximum performance the chunk sizes should be divisible by <code class="docutils literal notranslate"><span class="pre">4</span></code> and
should not exceed 2 GB (2<sup>31</sup> bytes) in size. When there are
multiple chunk sizes provided by multiple handlers, Django will use the
smallest chunk size defined by any handler.</p>
<p>The default is 64*2<sup>10</sup> bytes, or 64 KB.</p>
</dd></dl>

<dl class="method">
<dt id="django.core.files.uploadhandler.FileUploadHandler.new_file">
<code class="descclassname">FileUploadHandler.</code><code class="descname">new_file</code>(<em>field_name</em>, <em>file_name</em>, <em>content_type</em>, <em>content_length</em>, <em>charset</em>, <em>content_type_extra</em>)<a class="reference internal" href="../../_modules/django/core/files/uploadhandler.html#FileUploadHandler.new_file"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.files.uploadhandler.FileUploadHandler.new_file" title="Permalink to this definition">¶</a></dt>
<dd><p>Callback signaling that a new file upload is starting. This is called
before any data has been fed to any upload handlers.</p>
<p><code class="docutils literal notranslate"><span class="pre">field_name</span></code> is a string name of the file <code class="docutils literal notranslate"><span class="pre">&lt;input&gt;</span></code> field.</p>
<p><code class="docutils literal notranslate"><span class="pre">file_name</span></code> is the unicode filename that was provided by the browser.</p>
<p><code class="docutils literal notranslate"><span class="pre">content_type</span></code> is the MIME type provided by the browser – E.g.
<code class="docutils literal notranslate"><span class="pre">'image/jpeg'</span></code>.</p>
<p><code class="docutils literal notranslate"><span class="pre">content_length</span></code> is the length of the image given by the browser.
Sometimes this won’t be provided and will be <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>
<p><code class="docutils literal notranslate"><span class="pre">charset</span></code> is the character set (i.e. <code class="docutils literal notranslate"><span class="pre">utf8</span></code>) given by the browser.
Like <code class="docutils literal notranslate"><span class="pre">content_length</span></code>, this sometimes won’t be provided.</p>
<p><code class="docutils literal notranslate"><span class="pre">content_type_extra</span></code> is extra information about the file from the
<code class="docutils literal notranslate"><span class="pre">content-type</span></code> header. See <a class="reference internal" href="#django.core.files.uploadedfile.UploadedFile.content_type_extra" title="django.core.files.uploadedfile.UploadedFile.content_type_extra"><code class="xref py py-attr docutils literal notranslate"><span class="pre">UploadedFile.content_type_extra</span></code></a>.</p>
<p>This method may raise a <code class="docutils literal notranslate"><span class="pre">StopFutureHandlers</span></code> exception to prevent
future handlers from handling this file.</p>
</dd></dl>

<dl class="method">
<dt id="django.core.files.uploadhandler.FileUploadHandler.upload_complete">
<code class="descclassname">FileUploadHandler.</code><code class="descname">upload_complete</code>()<a class="reference internal" href="../../_modules/django/core/files/uploadhandler.html#FileUploadHandler.upload_complete"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.files.uploadhandler.FileUploadHandler.upload_complete" title="Permalink to this definition">¶</a></dt>
<dd><p>Callback signaling that the entire upload (all files) has completed.</p>
</dd></dl>

<dl class="method">
<dt id="django.core.files.uploadhandler.FileUploadHandler.handle_raw_input">
<code class="descclassname">FileUploadHandler.</code><code class="descname">handle_raw_input</code>(<em>input_data</em>, <em>META</em>, <em>content_length</em>, <em>boundary</em>, <em>encoding</em>)<a class="reference internal" href="../../_modules/django/core/files/uploadhandler.html#FileUploadHandler.handle_raw_input"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.core.files.uploadhandler.FileUploadHandler.handle_raw_input" title="Permalink to this definition">¶</a></dt>
<dd><p>Allows the handler to completely override the parsing of the raw
HTTP input.</p>
<p><code class="docutils literal notranslate"><span class="pre">input_data</span></code> is a file-like object that supports <code class="docutils literal notranslate"><span class="pre">read()</span></code>-ing.</p>
<p><code class="docutils literal notranslate"><span class="pre">META</span></code> is the same object as <code class="docutils literal notranslate"><span class="pre">request.META</span></code>.</p>
<p><code class="docutils literal notranslate"><span class="pre">content_length</span></code> is the length of the data in <code class="docutils literal notranslate"><span class="pre">input_data</span></code>. Don’t
read more than <code class="docutils literal notranslate"><span class="pre">content_length</span></code> bytes from <code class="docutils literal notranslate"><span class="pre">input_data</span></code>.</p>
<p><code class="docutils literal notranslate"><span class="pre">boundary</span></code> is the MIME boundary for this request.</p>
<p><code class="docutils literal notranslate"><span class="pre">encoding</span></code> is the encoding of the request.</p>
<p>Return <code class="docutils literal notranslate"><span class="pre">None</span></code> if you want upload handling to continue, or a tuple of
<code class="docutils literal notranslate"><span class="pre">(POST,</span> <span class="pre">FILES)</span></code> if you want to return the new data structures suitable
for the request directly.</p>
</dd></dl>

</div>
</div>
</div>


          </div>
        </div>
      </div>
      
        
          <div class="yui-b" id="sidebar">
            
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../../contents.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Uploaded Files and Upload Handlers</a><ul>
<li><a class="reference internal" href="#uploaded-files">Uploaded files</a></li>
<li><a class="reference internal" href="#module-django.core.files.uploadhandler">Built-in upload handlers</a></li>
<li><a class="reference internal" href="#writing-custom-upload-handlers">Writing custom upload handlers</a><ul>
<li><a class="reference internal" href="#required-methods">Required methods</a></li>
<li><a class="reference internal" href="#optional-methods">Optional methods</a></li>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="storage.html"
                        title="previous chapter">File storage API</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="../forms/index.html"
                        title="next chapter">Forms</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../../_sources/ref/files/uploads.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
              <h3>Last update:</h3>
              <p class="topless">Jun 03, 2019</p>
          </div>
        
      
    </div>

    <div id="ft">
      <div class="nav">
    &laquo; <a href="storage.html" title="File storage API">previous</a>
     |
    <a href="../index.html" title="API Reference" accesskey="U">up</a>
   |
    <a href="../forms/index.html" title="Forms">next</a> &raquo;</div>
    </div>
  </div>

      <div class="clearer"></div>
    </div>
  </body>
</html>